<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Time</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            Time 
            
                <span class="parent">&lt; 
                    
                    <a href="Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/time/acts_like_rb.html">activesupport/lib/active_support/core_ext/time/acts_like.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/time/calculations_rb.html">activesupport/lib/active_support/core_ext/time/calculations.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/time/conversions_rb.html">activesupport/lib/active_support/core_ext/time/conversions.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/time/marshal_rb.html">activesupport/lib/active_support/core_ext/time/marshal.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/core_ext/time/zones_rb.html">activesupport/lib/active_support/core_ext/time/zones.rb</a></li>
            
            <li><a href="../files/activesupport/lib/active_support/json/encoding_rb.html">activesupport/lib/active_support/json/encoding.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-2D">-</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-3C-3D-3E">&lt;=&gt;</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-3D-3D-3D">===</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-_dump">_dump</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-_dump_without_zone">_dump_without_zone</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-_load">_load</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-_load_without_zone">_load_without_zone</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>A</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-acts_like_time-3F">acts_like_time?</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-advance">advance</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-ago">ago</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-all_day">all_day</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-all_month">all_month</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-all_quarter">all_quarter</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-all_week">all_week</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-all_year">all_year</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-at">at</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_beginning_of_day">at_beginning_of_day</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_beginning_of_hour">at_beginning_of_hour</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_beginning_of_minute">at_beginning_of_minute</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_end_of_day">at_end_of_day</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_end_of_hour">at_end_of_hour</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_end_of_minute">at_end_of_minute</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-at_midnight">at_midnight</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-at_with_coercion">at_with_coercion</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-at_without_coercion">at_without_coercion</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>B</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-beginning_of_day">beginning_of_day</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-beginning_of_hour">beginning_of_hour</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-beginning_of_minute">beginning_of_minute</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-change">change</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-compare_with_coercion">compare_with_coercion</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-compare_without_coercion">compare_without_coercion</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-current">current</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>D</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-c-days_in_month">days_in_month</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-end_of_day">end_of_day</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-end_of_hour">end_of_hour</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-end_of_minute">end_of_minute</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-eql-3F">eql?</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-eql_with_coercion">eql_with_coercion</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-eql_without_coercion">eql_without_coercion</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-c-find_zone">find_zone</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-find_zone-21">find_zone!</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-formatted_offset">formatted_offset</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>I</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-in">in</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-in_time_zone">in_time_zone</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>L</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-c-local_time">local_time</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>M</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-midnight">midnight</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-minus_with_coercion">minus_with_coercion</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-minus_without_coercion">minus_without_coercion</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-minus_without_duration">minus_without_duration</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>S</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-i-seconds_since_midnight">seconds_since_midnight</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-seconds_until_end_of_day">seconds_until_end_of_day</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-since">since</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-c-time_with_datetime_fallback">time_with_datetime_fallback</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-to_default_s">to_default_s</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-to_formatted_s">to_formatted_s</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-i-to_s">to_s</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>U</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-c-use_zone">use_zone</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-utc_time">utc_time</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>Z</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Time.html#method-c-zone">zone</a>,
              </li>
            
              
              <li>
                <a href="Time.html#method-c-zone-3D">zone=</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  
    <!-- Includes -->
    <div class="sectiontitle">Included Modules</div>
    <ul>
      
        <li>
          
            <a href="DateAndTime/Calculations.html">
              DateAndTime::Calculations
            </a>
          
        </li>
      
    </ul>
  



  

    

    

    
      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class="attr-name">COMMON_YEAR_DAYS_IN_MONTH</td>
            <td>=</td>
            <td class="attr-value">[nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
          <tr valign='top'>
            <td class="attr-name">DATE_FORMATS</td>
            <td>=</td>
            <td class="attr-value">{
:db           =&gt; '%Y-%m-%d %H:%M:%S',
:number       =&gt; '%Y%m%d%H%M%S',
:nsec         =&gt; '%Y%m%d%H%M%S%9N',
:time         =&gt; '%H:%M',
:short        =&gt; '%d %b %H:%M',
:long         =&gt; '%B %d, %Y %H:%M',
:long_ordinal =&gt; lambda { |time|
day_format = ActiveSupport::Inflector.ordinalize(time.day)
time.strftime(&quot;%B #{day_format}, %Y %H:%M&quot;)
},
:rfc822       =&gt; lambda { |time|
offset_format = time.formatted_offset(false)
time.strftime(&quot;%a, %d %b %Y %H:%M:%S #{offset_format}&quot;)
}
}</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
      </table>
    


    
      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>zone_default</td>
            <td class='attr-desc'></td>
          </tr>
        
      </table>
    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-3D-3D-3D">
            
              <b>===</b>(other)
            
            <a href="Time.html#method-c-3D-3D-3D" name="method-c-3D-3D-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Overriding case equality method so that it returns true for <a
href="ActiveSupport/TimeWithZone.html">ActiveSupport::TimeWithZone</a>
instances</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-3D-3D-3D_source')" id="l_method-c-3D-3D-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L15" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-3D-3D-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 15</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">===</span>(<span class="ruby-keyword ruby-title">other</span>)
  <span class="ruby-keyword">super</span> <span class="ruby-operator">||</span> (<span class="ruby-keyword">self</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Time</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeWithZone</span>))
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-_load">
            
              <b>_load</b>(marshaled_time)
            
            <a href="Time.html#method-c-_load" name="method-c-_load" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-c-_load_without_zone">_load_without_zone</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-_load_source')" id="l_method-c-_load_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/baa4d79cb101e7a65b0399b20eebd5dd5cce0cf1/activesupport/lib/active_support/core_ext/time/marshal.rb#L8" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-_load_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/marshal.rb, line 8</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">_load</span>(<span class="ruby-identifier">marshaled_time</span>)
  <span class="ruby-identifier">time</span> = <span class="ruby-identifier">_load_without_zone</span>(<span class="ruby-identifier">marshaled_time</span>)
  <span class="ruby-identifier">time</span>.<span class="ruby-identifier">instance_eval</span> <span class="ruby-keyword">do</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">zone</span> = <span class="ruby-keyword">defined?</span>(<span class="ruby-ivar">@_zone</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">remove_instance_variable</span>(<span class="ruby-string">'@_zone'</span>)
      <span class="ruby-identifier">ary</span> = <span class="ruby-identifier">to_a</span>
      <span class="ruby-identifier">ary</span>[<span class="ruby-number">0</span>] <span class="ruby-operator">+=</span> <span class="ruby-identifier">subsec</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">ary</span>[<span class="ruby-number">0</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">sec</span>
      <span class="ruby-identifier">ary</span>[<span class="ruby-number">-1</span>] = <span class="ruby-identifier">zone</span>
      <span class="ruby-identifier">utc?</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">utc</span>(*<span class="ruby-identifier">ary</span>) <span class="ruby-operator">:</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(*<span class="ruby-identifier">ary</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">self</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-_load_without_zone">
            
              <b>_load_without_zone</b>(marshaled_time)
            
            <a href="Time.html#method-c-_load_without_zone" name="method-c-_load_without_zone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-at">
            
              <b>at</b>(*args)
            
            <a href="Time.html#method-c-at" name="method-c-at" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-c-at_without_coercion">at_without_coercion</a>
            </div>
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-at_with_coercion">
            
              <b>at_with_coercion</b>(*args)
            
            <a href="Time.html#method-c-at_with_coercion" name="method-c-at_with_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Layers additional behavior on <a href="Time.html#method-c-at">::at</a> so
that <a
href="ActiveSupport/TimeWithZone.html">ActiveSupport::TimeWithZone</a> and
<a href="DateTime.html">DateTime</a> instances can be used when called with
a single argument</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-c-at">at</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-at_with_coercion_source')" id="l_method-c-at_with_coercion_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L71" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-at_with_coercion_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 71</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">at_with_coercion</span>(*<span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-number">1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">acts_like?</span>(<span class="ruby-value">:time</span>)
    <span class="ruby-identifier">at_without_coercion</span>(<span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span>.<span class="ruby-identifier">to_i</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">at_without_coercion</span>(*<span class="ruby-identifier">args</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-at_without_coercion">
            
              <b>at_without_coercion</b>(*args)
            
            <a href="Time.html#method-c-at_without_coercion" name="method-c-at_without_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-current">
            
              <b>current</b>()
            
            <a href="Time.html#method-c-current" name="method-c-current" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns <code>Time.zone.now</code> when <code>Time.zone</code> or
<code>config.time_zone</code> are set, otherwise just returns
<code>Time.now</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-current_source')" id="l_method-c-current_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L65" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-current_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 65</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">current</span>
  <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span> <span class="ruby-operator">?</span> <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">:</span> <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-days_in_month">
            
              <b>days_in_month</b>(month, year = now.year)
            
            <a href="Time.html#method-c-days_in_month" name="method-c-days_in_month" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Return the number of days in the given month. If no year is specified, it
will use the current year.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-days_in_month_source')" id="l_method-c-days_in_month_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L21" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-days_in_month_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 21</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">days_in_month</span>(<span class="ruby-identifier">month</span>, <span class="ruby-identifier">year</span> = <span class="ruby-identifier">now</span>.<span class="ruby-identifier">year</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">month</span> <span class="ruby-operator">==</span> <span class="ruby-number">2</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">::</span><span class="ruby-constant">Date</span>.<span class="ruby-identifier">gregorian_leap?</span>(<span class="ruby-identifier">year</span>)
    <span class="ruby-number">29</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-constant">COMMON_YEAR_DAYS_IN_MONTH</span>[<span class="ruby-identifier">month</span>]
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-find_zone">
            
              <b>find_zone</b>(time_zone)
            
            <a href="Time.html#method-c-find_zone" name="method-c-find_zone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-find_zone_source')" id="l_method-c-find_zone_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/ded5f5b261b324767406baca41193c08c966008a/activesupport/lib/active_support/core_ext/time/zones.rb#L72" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-find_zone_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/zones.rb, line 72</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">find_zone</span>(<span class="ruby-identifier">time_zone</span>)
  <span class="ruby-identifier">find_zone!</span>(<span class="ruby-identifier">time_zone</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-find_zone-21">
            
              <b>find_zone!</b>(time_zone)
            
            <a href="Time.html#method-c-find_zone-21" name="method-c-find_zone-21" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a TimeZone instance or nil, or raises an ArgumentError for invalid
timezones.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-find_zone-21_source')" id="l_method-c-find_zone-21_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/ded5f5b261b324767406baca41193c08c966008a/activesupport/lib/active_support/core_ext/time/zones.rb#L52" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-find_zone-21_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/zones.rb, line 52</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">find_zone!</span>(<span class="ruby-identifier">time_zone</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">time_zone</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">time_zone</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeZone</span>)
    <span class="ruby-identifier">time_zone</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-comment"># lookup timezone based on identifier (unless we've been passed a TZInfo::Timezone)</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">time_zone</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:period_for_local</span>)
      <span class="ruby-identifier">time_zone</span> = <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeZone</span>[<span class="ruby-identifier">time_zone</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">TZInfo</span><span class="ruby-operator">::</span><span class="ruby-constant">Timezone</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">time_zone</span>)
    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># Return if a TimeZone instance, or wrap in a TimeZone instance if a TZInfo::Timezone</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">time_zone</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeZone</span>)
      <span class="ruby-identifier">time_zone</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeZone</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">time_zone</span>.<span class="ruby-identifier">name</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">time_zone</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">TZInfo</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidTimezoneIdentifier</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;Invalid Timezone: #{time_zone}&quot;</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-local_time">
            
              <b>local_time</b>(*args)
            
            <a href="Time.html#method-c-local_time" name="method-c-local_time" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p><strong>DEPRECATED</strong>: Use +Time#local+ instead.</p>

<p>Wraps class method <code>time_with_datetime_fallback</code> with
<code>utc_or_local</code> set to <code>:local</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-local_time_source')" id="l_method-c-local_time_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L59" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-local_time_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 59</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">local_time</span>(*<span class="ruby-identifier">args</span>)
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">'local_time is deprecated. Use Time#local instead'</span>, <span class="ruby-identifier">caller</span>
  <span class="ruby-identifier">time_with_datetime_fallback</span>(<span class="ruby-value">:local</span>, *<span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-time_with_datetime_fallback">
            
              <b>time_with_datetime_fallback</b>(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0)
            
            <a href="Time.html#method-c-time_with_datetime_fallback" name="method-c-time_with_datetime_fallback" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p><strong>DEPRECATED</strong>: Use +Time#utc+ or +Time#local+ instead.</p>

<p>Returns a new <a href="Time.html">Time</a> if requested year can be
accommodated by Ruby’s <a href="Time.html">Time</a> class (i.e., if year is
within either 1970..2038 or 1902..2038, depending on system architecture);
otherwise returns a <a href="DateTime.html">DateTime</a>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-time_with_datetime_fallback_source')" id="l_method-c-time_with_datetime_fallback_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L34" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-time_with_datetime_fallback_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">time_with_datetime_fallback</span>(<span class="ruby-identifier">utc_or_local</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>=<span class="ruby-number">1</span>, <span class="ruby-identifier">day</span>=<span class="ruby-number">1</span>, <span class="ruby-identifier">hour</span>=<span class="ruby-number">0</span>, <span class="ruby-identifier">min</span>=<span class="ruby-number">0</span>, <span class="ruby-identifier">sec</span>=<span class="ruby-number">0</span>, <span class="ruby-identifier">usec</span>=<span class="ruby-number">0</span>)
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">'time_with_datetime_fallback is deprecated. Use Time#utc or Time#local instead'</span>, <span class="ruby-identifier">caller</span>
  <span class="ruby-identifier">time</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">utc_or_local</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>, <span class="ruby-identifier">usec</span>)

  <span class="ruby-comment"># This check is needed because Time.utc(y) returns a time object in the 2000s for 0 &lt;= y &lt;= 138.</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">year</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">year</span>
    <span class="ruby-identifier">time</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil_from_format</span>(<span class="ruby-identifier">utc_or_local</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-operator">::</span><span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">civil_from_format</span>(<span class="ruby-identifier">utc_or_local</span>, <span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>, <span class="ruby-identifier">hour</span>, <span class="ruby-identifier">min</span>, <span class="ruby-identifier">sec</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-use_zone">
            
              <b>use_zone</b>(time_zone)
            
            <a href="Time.html#method-c-use_zone" name="method-c-use_zone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Allows override of <code>Time.zone</code> locally inside supplied block;
resets <code>Time.zone</code> to existing value when done.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-use_zone_source')" id="l_method-c-use_zone_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/ded5f5b261b324767406baca41193c08c966008a/activesupport/lib/active_support/core_ext/time/zones.rb#L41" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-use_zone_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/zones.rb, line 41</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">use_zone</span>(<span class="ruby-identifier">time_zone</span>)
  <span class="ruby-identifier">new_zone</span> = <span class="ruby-identifier">find_zone!</span>(<span class="ruby-identifier">time_zone</span>)
  <span class="ruby-keyword">begin</span>
    <span class="ruby-identifier">old_zone</span>, <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span>, <span class="ruby-identifier">new_zone</span>
    <span class="ruby-keyword">yield</span>
  <span class="ruby-keyword">ensure</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span> = <span class="ruby-identifier">old_zone</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-utc_time">
            
              <b>utc_time</b>(*args)
            
            <a href="Time.html#method-c-utc_time" name="method-c-utc_time" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p><strong>DEPRECATED</strong>: Use +Time#utc+ instead.</p>

<p>Wraps class method <code>time_with_datetime_fallback</code> with
<code>utc_or_local</code> set to <code>:utc</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-utc_time_source')" id="l_method-c-utc_time_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L51" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-utc_time_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 51</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">utc_time</span>(*<span class="ruby-identifier">args</span>)
  <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">Deprecation</span>.<span class="ruby-identifier">warn</span> <span class="ruby-string">'utc_time is deprecated. Use Time#utc instead'</span>, <span class="ruby-identifier">caller</span>
  <span class="ruby-identifier">time_with_datetime_fallback</span>(<span class="ruby-value">:utc</span>, *<span class="ruby-identifier">args</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-zone">
            
              <b>zone</b>()
            
            <a href="Time.html#method-c-zone" name="method-c-zone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the TimeZone for the current request, if this has been set (via <a
href="Time.html#method-c-zone-3D">::zone=</a>). If <code>Time.zone</code>
has not been set for the current request, returns the TimeZone specified in
<code>config.time_zone</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-zone_source')" id="l_method-c-zone_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/ded5f5b261b324767406baca41193c08c966008a/activesupport/lib/active_support/core_ext/time/zones.rb#L9" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-zone_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/zones.rb, line 9</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">zone</span>
  <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-value">:time_zone</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">zone_default</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-c-zone-3D">
            
              <b>zone=</b>(time_zone)
            
            <a href="Time.html#method-c-zone-3D" name="method-c-zone-3D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Sets <code>Time.zone</code> to a TimeZone object for the current
request/thread.</p>

<p>This method accepts any of the following:</p>
<ul><li>
<p>A <a href="Rails.html">Rails</a> TimeZone object.</p>
</li><li>
<p>An identifier for a <a href="Rails.html">Rails</a> TimeZone object (e.g.,
“Eastern <a href="Time.html">Time</a> (US &amp; Canada)”,
<code>-5.hours</code>).</p>
</li><li>
<p>A TZInfo::Timezone object.</p>
</li><li>
<p>An identifier for a TZInfo::Timezone object (e.g., “America/New_York”).</p>
</li></ul>

<p>Here’s an example of how you might set <code>Time.zone</code> on a per
request basis and reset it when the request is done.
<code>current_user.time_zone</code> just needs to return a string
identifying the user’s preferred time zone:</p>

<pre class="ruby"><span class="ruby-keyword">class</span> <span class="ruby-constant">ApplicationController</span> <span class="ruby-operator">&lt;</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>
  <span class="ruby-identifier">around_filter</span> :<span class="ruby-identifier">set_time_zone</span>

  <span class="ruby-keyword">def</span> <span class="ruby-identifier">set_time_zone</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">logged_in?</span>
      <span class="ruby-constant">Time</span>.<span class="ruby-identifier">use_zone</span>(<span class="ruby-identifier">current_user</span>.<span class="ruby-identifier">time_zone</span>) { <span class="ruby-keyword">yield</span> }
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">yield</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-zone-3D_source')" id="l_method-c-zone-3D_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/ded5f5b261b324767406baca41193c08c966008a/activesupport/lib/active_support/core_ext/time/zones.rb#L36" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-zone-3D_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/zones.rb, line 36</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">zone=</span>(<span class="ruby-identifier">time_zone</span>)
  <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-value">:time_zone</span>] = <span class="ruby-identifier">find_zone!</span>(<span class="ruby-identifier">time_zone</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-2D">
            
              <b>-</b>(other)
            
            <a href="Time.html#method-i-2D" name="method-i-2D" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-minus_without_duration">minus_without_duration</a>, <a href="Time.html#method-i-minus_without_coercion">minus_without_coercion</a>
            </div>
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-3C-3D-3E">
            
              <b>&lt;=&gt;</b>(other)
            
            <a href="Time.html#method-i-3C-3D-3E" name="method-i-3C-3D-3E" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-compare_without_coercion">compare_without_coercion</a>
            </div>
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-_dump">
            
              <b>_dump</b>(*args)
            
            <a href="Time.html#method-i-_dump" name="method-i-_dump" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-_dump_without_zone">_dump_without_zone</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-_dump_source')" id="l_method-i-_dump_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/baa4d79cb101e7a65b0399b20eebd5dd5cce0cf1/activesupport/lib/active_support/core_ext/time/marshal.rb#L24" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-_dump_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/marshal.rb, line 24</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">_dump</span>(*<span class="ruby-identifier">args</span>)
  <span class="ruby-identifier">obj</span> = <span class="ruby-identifier">dup</span>
  <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-string">'@_zone'</span>, <span class="ruby-identifier">zone</span>)
  <span class="ruby-identifier">obj</span>.<span class="ruby-identifier">send</span> <span class="ruby-value">:_dump_without_zone</span>, *<span class="ruby-identifier">args</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-_dump_without_zone">
            
              <b>_dump_without_zone</b>(*args)
            
            <a href="Time.html#method-i-_dump_without_zone" name="method-i-_dump_without_zone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-acts_like_time-3F">
            
              <b>acts_like_time?</b>()
            
            <a href="Time.html#method-i-acts_like_time-3F" name="method-i-acts_like_time-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Duck-types as a Time-like class. See <a
href="Object.html#method-i-acts_like-3F">Object#acts_like?</a>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-acts_like_time-3F_source')" id="l_method-i-acts_like_time-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/609c1988d2e274b365c5299cc5933fb6855e4175/activesupport/lib/active_support/core_ext/time/acts_like.rb#L5" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-acts_like_time-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/acts_like.rb, line 5</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">acts_like_time?</span>
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-advance">
            
              <b>advance</b>(options)
            
            <a href="Time.html#method-i-advance" name="method-i-advance" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Uses <a href="Date.html">Date</a> to provide precise <a
href="Time.html">Time</a> calculations for years, months, and days. The
<code>options</code> parameter takes a hash with any of these keys:
<code>:years</code>, <code>:months</code>, <code>:weeks</code>,
<code>:days</code>, <code>:hours</code>, <code>:minutes</code>,
<code>:seconds</code>.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-advance_source')" id="l_method-i-advance_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L129" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-advance_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 129</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">advance</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:weeks</span>].<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:weeks</span>], <span class="ruby-identifier">partial_weeks</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:weeks</span>].<span class="ruby-identifier">divmod</span>(<span class="ruby-number">1</span>)
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:days</span>] = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:days</span>, <span class="ruby-number">0</span>) <span class="ruby-operator">+</span> <span class="ruby-number">7</span> * <span class="ruby-identifier">partial_weeks</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:days</span>].<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:days</span>], <span class="ruby-identifier">partial_days</span> = <span class="ruby-identifier">options</span>[<span class="ruby-value">:days</span>].<span class="ruby-identifier">divmod</span>(<span class="ruby-number">1</span>)
    <span class="ruby-identifier">options</span>[<span class="ruby-value">:hours</span>] = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:hours</span>, <span class="ruby-number">0</span>) <span class="ruby-operator">+</span> <span class="ruby-number">24</span> * <span class="ruby-identifier">partial_days</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">d</span> = <span class="ruby-identifier">to_date</span>.<span class="ruby-identifier">advance</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">time_advanced_by_date</span> = <span class="ruby-identifier">change</span>(<span class="ruby-value">:year</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">year</span>, <span class="ruby-value">:month</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">month</span>, <span class="ruby-value">:day</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">day</span>)
  <span class="ruby-identifier">seconds_to_advance</span> =        <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:seconds</span>, <span class="ruby-number">0</span>) <span class="ruby-operator">+</span>
    <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:minutes</span>, <span class="ruby-number">0</span>) * <span class="ruby-number">60</span> <span class="ruby-operator">+</span>
    <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:hours</span>, <span class="ruby-number">0</span>) * <span class="ruby-number">3600</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">seconds_to_advance</span>.<span class="ruby-identifier">zero?</span>
    <span class="ruby-identifier">time_advanced_by_date</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">time_advanced_by_date</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds_to_advance</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-ago">
            
              <b>ago</b>(seconds)
            
            <a href="Time.html#method-i-ago" name="method-i-ago" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the time a number
of seconds ago, this is basically a wrapper around the <a
href="Numeric.html">Numeric</a> extension</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-ago_source')" id="l_method-i-ago_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L155" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-ago_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 155</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">ago</span>(<span class="ruby-identifier">seconds</span>)
  <span class="ruby-identifier">since</span>(<span class="ruby-operator">-</span><span class="ruby-identifier">seconds</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-all_day">
            
              <b>all_day</b>()
            
            <a href="Time.html#method-i-all_day" name="method-i-all_day" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a <a href="Range.html">Range</a> representing the whole day of the
current time.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-all_day_source')" id="l_method-i-all_day_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L219" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-all_day_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 219</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">all_day</span>
  <span class="ruby-identifier">beginning_of_day</span><span class="ruby-operator">..</span><span class="ruby-identifier">end_of_day</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-all_month">
            
              <b>all_month</b>()
            
            <a href="Time.html#method-i-all_month" name="method-i-all_month" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a <a href="Range.html">Range</a> representing the whole month of
the current time.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-all_month_source')" id="l_method-i-all_month_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L230" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-all_month_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 230</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">all_month</span>
  <span class="ruby-identifier">beginning_of_month</span><span class="ruby-operator">..</span><span class="ruby-identifier">end_of_month</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-all_quarter">
            
              <b>all_quarter</b>()
            
            <a href="Time.html#method-i-all_quarter" name="method-i-all_quarter" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a <a href="Range.html">Range</a> representing the whole quarter of
the current time.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-all_quarter_source')" id="l_method-i-all_quarter_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L235" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-all_quarter_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 235</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">all_quarter</span>
  <span class="ruby-identifier">beginning_of_quarter</span><span class="ruby-operator">..</span><span class="ruby-identifier">end_of_quarter</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-all_week">
            
              <b>all_week</b>(start_day = Date.beginning_of_week)
            
            <a href="Time.html#method-i-all_week" name="method-i-all_week" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a <a href="Range.html">Range</a> representing the whole week of the
current time. Week starts on start_day, default is
<code>Date.week_start</code> or <code>config.week_start</code> when set.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-all_week_source')" id="l_method-i-all_week_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L225" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-all_week_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 225</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">all_week</span>(<span class="ruby-identifier">start_day</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">beginning_of_week</span>)
  <span class="ruby-identifier">beginning_of_week</span>(<span class="ruby-identifier">start_day</span>)<span class="ruby-operator">..</span><span class="ruby-identifier">end_of_week</span>(<span class="ruby-identifier">start_day</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-all_year">
            
              <b>all_year</b>()
            
            <a href="Time.html#method-i-all_year" name="method-i-all_year" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a <a href="Range.html">Range</a> representing the whole year of the
current time.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-all_year_source')" id="l_method-i-all_year_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L240" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-all_year_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 240</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">all_year</span>
  <span class="ruby-identifier">beginning_of_year</span><span class="ruby-operator">..</span><span class="ruby-identifier">end_of_year</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_beginning_of_day">
            
              <b>at_beginning_of_day</b>()
            
            <a href="Time.html#method-i-at_beginning_of_day" name="method-i-at_beginning_of_day" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_beginning_of_hour">
            
              <b>at_beginning_of_hour</b>()
            
            <a href="Time.html#method-i-at_beginning_of_hour" name="method-i-at_beginning_of_hour" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_beginning_of_minute">
            
              <b>at_beginning_of_minute</b>()
            
            <a href="Time.html#method-i-at_beginning_of_minute" name="method-i-at_beginning_of_minute" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_end_of_day">
            
              <b>at_end_of_day</b>()
            
            <a href="Time.html#method-i-at_end_of_day" name="method-i-at_end_of_day" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_end_of_hour">
            
              <b>at_end_of_hour</b>()
            
            <a href="Time.html#method-i-at_end_of_hour" name="method-i-at_end_of_hour" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_end_of_minute">
            
              <b>at_end_of_minute</b>()
            
            <a href="Time.html#method-i-at_end_of_minute" name="method-i-at_end_of_minute" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-at_midnight">
            
              <b>at_midnight</b>()
            
            <a href="Time.html#method-i-at_midnight" name="method-i-at_midnight" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-beginning_of_day">
            
              <b>beginning_of_day</b>()
            
            <a href="Time.html#method-i-beginning_of_day" name="method-i-beginning_of_day" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the start of the
day (0:00)</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-midnight">midnight</a>, <a href="Time.html#method-i-at_midnight">at_midnight</a>, <a href="Time.html#method-i-at_beginning_of_day">at_beginning_of_day</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-beginning_of_day_source')" id="l_method-i-beginning_of_day_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L168" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-beginning_of_day_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 168</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">beginning_of_day</span>
  <span class="ruby-comment">#(self - seconds_since_midnight).change(usec: 0)</span>
  <span class="ruby-identifier">change</span>(<span class="ruby-value">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">0</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-beginning_of_hour">
            
              <b>beginning_of_hour</b>()
            
            <a href="Time.html#method-i-beginning_of_hour" name="method-i-beginning_of_hour" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the start of the
hour (x:00)</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-at_beginning_of_hour">at_beginning_of_hour</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-beginning_of_hour_source')" id="l_method-i-beginning_of_hour_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L188" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-beginning_of_hour_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 188</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">beginning_of_hour</span>
  <span class="ruby-identifier">change</span>(<span class="ruby-value">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">0</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-beginning_of_minute">
            
              <b>beginning_of_minute</b>()
            
            <a href="Time.html#method-i-beginning_of_minute" name="method-i-beginning_of_minute" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the start of the
minute (x:xx:00)</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-at_beginning_of_minute">at_beginning_of_minute</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-beginning_of_minute_source')" id="l_method-i-beginning_of_minute_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L204" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-beginning_of_minute_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 204</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">beginning_of_minute</span>
  <span class="ruby-identifier">change</span>(<span class="ruby-value">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">0</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-change">
            
              <b>change</b>(options)
            
            <a href="Time.html#method-i-change" name="method-i-change" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> where one or more of the
elements have been changed according to the <code>options</code> parameter.
The time options (<code>:hour</code>, <code>:min</code>, <code>:sec</code>,
<code>:usec</code>) reset cascadingly, so if only the hour is passed, then
minute, sec, and usec is set to 0. If the hour and minute is passed, then
sec and usec is set to 0.  The <code>options</code> parameter takes a hash
with any of these keys: <code>:year</code>, <code>:month</code>,
<code>:day</code>, <code>:hour</code>, <code>:min</code>,
<code>:sec</code>, <code>:usec</code>.</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2012</span>, <span class="ruby-value">8</span>, <span class="ruby-value">29</span>, <span class="ruby-value">22</span>, <span class="ruby-value">35</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">change</span>(<span class="ruby-identifier">day</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>)              <span class="ruby-comment"># =&gt; Time.new(2012, 8, 1, 22, 35, 0)</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2012</span>, <span class="ruby-value">8</span>, <span class="ruby-value">29</span>, <span class="ruby-value">22</span>, <span class="ruby-value">35</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">change</span>(<span class="ruby-identifier">year</span><span class="ruby-operator">:</span> <span class="ruby-value">1981</span>, <span class="ruby-identifier">day</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span>)  <span class="ruby-comment"># =&gt; Time.new(1981, 8, 1, 22, 35, 0)</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2012</span>, <span class="ruby-value">8</span>, <span class="ruby-value">29</span>, <span class="ruby-value">22</span>, <span class="ruby-value">35</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">change</span>(<span class="ruby-identifier">year</span><span class="ruby-operator">:</span> <span class="ruby-value">1981</span>, <span class="ruby-identifier">hour</span><span class="ruby-operator">:</span> <span class="ruby-value">0</span>) <span class="ruby-comment"># =&gt; Time.new(1981, 8, 29, 0, 0, 0)</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-change_source')" id="l_method-i-change_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L107" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-change_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 107</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">change</span>(<span class="ruby-identifier">options</span>)
  <span class="ruby-identifier">new_year</span>  = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:year</span>, <span class="ruby-identifier">year</span>)
  <span class="ruby-identifier">new_month</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:month</span>, <span class="ruby-identifier">month</span>)
  <span class="ruby-identifier">new_day</span>   = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:day</span>, <span class="ruby-identifier">day</span>)
  <span class="ruby-identifier">new_hour</span>  = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:hour</span>, <span class="ruby-identifier">hour</span>)
  <span class="ruby-identifier">new_min</span>   = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:min</span>, <span class="ruby-identifier">options</span>[<span class="ruby-value">:hour</span>] <span class="ruby-operator">?</span> <span class="ruby-number">0</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">min</span>)
  <span class="ruby-identifier">new_sec</span>   = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:sec</span>, (<span class="ruby-identifier">options</span>[<span class="ruby-value">:hour</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:min</span>]) <span class="ruby-operator">?</span> <span class="ruby-number">0</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">sec</span>)
  <span class="ruby-identifier">new_usec</span>  = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">fetch</span>(<span class="ruby-value">:usec</span>, (<span class="ruby-identifier">options</span>[<span class="ruby-value">:hour</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:min</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:sec</span>]) <span class="ruby-operator">?</span> <span class="ruby-number">0</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Rational</span>(<span class="ruby-identifier">nsec</span>, <span class="ruby-number">1000</span>))

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">utc?</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">utc</span>(<span class="ruby-identifier">new_year</span>, <span class="ruby-identifier">new_month</span>, <span class="ruby-identifier">new_day</span>, <span class="ruby-identifier">new_hour</span>, <span class="ruby-identifier">new_min</span>, <span class="ruby-identifier">new_sec</span>, <span class="ruby-identifier">new_usec</span>)
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">zone</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(<span class="ruby-identifier">new_year</span>, <span class="ruby-identifier">new_month</span>, <span class="ruby-identifier">new_day</span>, <span class="ruby-identifier">new_hour</span>, <span class="ruby-identifier">new_min</span>, <span class="ruby-identifier">new_sec</span>, <span class="ruby-identifier">new_usec</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">new_year</span>, <span class="ruby-identifier">new_month</span>, <span class="ruby-identifier">new_day</span>, <span class="ruby-identifier">new_hour</span>, <span class="ruby-identifier">new_min</span>, <span class="ruby-identifier">new_sec</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">new_usec</span>.<span class="ruby-identifier">to_r</span> <span class="ruby-operator">/</span> <span class="ruby-number">1000000</span>), <span class="ruby-identifier">utc_offset</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-compare_with_coercion">
            
              <b>compare_with_coercion</b>(other)
            
            <a href="Time.html#method-i-compare_with_coercion" name="method-i-compare_with_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Layers additional behavior on Time#&lt;=&gt; so that <a
href="DateTime.html">DateTime</a> and <a
href="ActiveSupport/TimeWithZone.html">ActiveSupport::TimeWithZone</a>
instances can be chronologically compared with a <a
href="Time.html">Time</a></p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-3C-3D-3E">&lt;=&gt;</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-compare_with_coercion_source')" id="l_method-i-compare_with_coercion_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L276" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-compare_with_coercion_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 276</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">compare_with_coercion</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-comment"># we're avoiding Time#to_datetime cause it's expensive</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Time</span>)
    <span class="ruby-identifier">compare_without_coercion</span>(<span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_time</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">to_datetime</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">other</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-compare_without_coercion">
            
              <b>compare_without_coercion</b>(other)
            
            <a href="Time.html#method-i-compare_without_coercion" name="method-i-compare_without_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-end_of_day">
            
              <b>end_of_day</b>()
            
            <a href="Time.html#method-i-end_of_day" name="method-i-end_of_day" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the end of the day,
23:59:59.999999 (.999999999 in ruby1.9)</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-at_end_of_day">at_end_of_day</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-end_of_day_source')" id="l_method-i-end_of_day_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L177" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-end_of_day_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 177</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">end_of_day</span>
  <span class="ruby-identifier">change</span>(
    <span class="ruby-value">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">23</span>,
    <span class="ruby-value">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">59</span>,
    <span class="ruby-value">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">59</span>,
    <span class="ruby-value">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Rational</span>(<span class="ruby-number">999999999</span>, <span class="ruby-number">1000</span>)
  )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-end_of_hour">
            
              <b>end_of_hour</b>()
            
            <a href="Time.html#method-i-end_of_hour" name="method-i-end_of_hour" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the end of the
hour, x:59:59.999999 (.999999999 in ruby1.9)</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-at_end_of_hour">at_end_of_hour</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-end_of_hour_source')" id="l_method-i-end_of_hour_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L194" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-end_of_hour_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 194</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">end_of_hour</span>
  <span class="ruby-identifier">change</span>(
    <span class="ruby-value">:min</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">59</span>,
    <span class="ruby-value">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">59</span>,
    <span class="ruby-value">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Rational</span>(<span class="ruby-number">999999999</span>, <span class="ruby-number">1000</span>)
  )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-end_of_minute">
            
              <b>end_of_minute</b>()
            
            <a href="Time.html#method-i-end_of_minute" name="method-i-end_of_minute" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the end of the
minute, x:xx:59.999999 (.999999999 in ruby1.9)</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-at_end_of_minute">at_end_of_minute</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-end_of_minute_source')" id="l_method-i-end_of_minute_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L210" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-end_of_minute_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 210</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">end_of_minute</span>
  <span class="ruby-identifier">change</span>(
    <span class="ruby-value">:sec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">59</span>,
    <span class="ruby-value">:usec</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Rational</span>(<span class="ruby-number">999999999</span>, <span class="ruby-number">1000</span>)
  )
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-eql-3F">
            
              <b>eql?</b>(other)
            
            <a href="Time.html#method-i-eql-3F" name="method-i-eql-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-eql_without_coercion">eql_without_coercion</a>
            </div>
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-eql_with_coercion">
            
              <b>eql_with_coercion</b>(other)
            
            <a href="Time.html#method-i-eql_with_coercion" name="method-i-eql_with_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Layers additional behavior on <a href="Time.html#method-i-eql-3F">#eql?</a>
so that <a
href="ActiveSupport/TimeWithZone.html">ActiveSupport::TimeWithZone</a>
instances can be eql? to an equivalent <a href="Time.html">Time</a></p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-eql-3F">eql?</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-eql_with_coercion_source')" id="l_method-i-eql_with_coercion_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L289" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-eql_with_coercion_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 289</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">eql_with_coercion</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-comment"># if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do eql? comparison</span>
  <span class="ruby-identifier">other</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">comparable_time</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:comparable_time</span>)
  <span class="ruby-identifier">eql_without_coercion</span>(<span class="ruby-identifier">other</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-eql_without_coercion">
            
              <b>eql_without_coercion</b>(other)
            
            <a href="Time.html#method-i-eql_without_coercion" name="method-i-eql_without_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-formatted_offset">
            
              <b>formatted_offset</b>(colon = true, alternate_utc_string = nil)
            
            <a href="Time.html#method-i-formatted_offset" name="method-i-formatted_offset" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the UTC offset as an +HH:MM formatted string.</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(<span class="ruby-value">2000</span>).<span class="ruby-identifier">formatted_offset</span>        <span class="ruby-comment"># =&gt; &quot;-06:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">local</span>(<span class="ruby-value">2000</span>).<span class="ruby-identifier">formatted_offset</span>(<span class="ruby-keyword">false</span>) <span class="ruby-comment"># =&gt; &quot;-0600&quot;</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-formatted_offset_source')" id="l_method-i-formatted_offset_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/794a70f94485fb64ed1c49ba8532895306e2001c/activesupport/lib/active_support/core_ext/time/conversions.rb#L60" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-formatted_offset_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/conversions.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">formatted_offset</span>(<span class="ruby-identifier">colon</span> = <span class="ruby-keyword">true</span>, <span class="ruby-identifier">alternate_utc_string</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-identifier">utc?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">alternate_utc_string</span> <span class="ruby-operator">||</span> <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeZone</span>.<span class="ruby-identifier">seconds_to_utc_offset</span>(<span class="ruby-identifier">utc_offset</span>, <span class="ruby-identifier">colon</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-in">
            
              <b>in</b>(seconds)
            
            <a href="Time.html#method-i-in" name="method-i-in" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-in_time_zone">
            
              <b>in_time_zone</b>(zone = ::Time.zone)
            
            <a href="Time.html#method-i-in_time_zone" name="method-i-in_time_zone" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the simultaneous time in <code>Time.zone</code>.</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span> = <span class="ruby-string">'Hawaii'</span>        <span class="ruby-comment"># =&gt; 'Hawaii'</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">utc</span>(<span class="ruby-value">2000</span>).<span class="ruby-identifier">in_time_zone</span> <span class="ruby-comment"># =&gt; Fri, 31 Dec 1999 14:00:00 HST -10:00</span>
</pre>

<p>This method is similar to Time#localtime, except that it uses
<code>Time.zone</code> as the local zone instead of the operating system’s
time zone.</p>

<p>You can also pass in a TimeZone instance or string that identifies a
TimeZone as an argument, and the conversion will be based on that zone
instead of <code>Time.zone</code>.</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">utc</span>(<span class="ruby-value">2000</span>).<span class="ruby-identifier">in_time_zone</span>(<span class="ruby-string">'Alaska'</span>) <span class="ruby-comment"># =&gt; Fri, 31 Dec 1999 15:00:00 AKST -09:00</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-in_time_zone_source')" id="l_method-i-in_time_zone_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/ded5f5b261b324767406baca41193c08c966008a/activesupport/lib/active_support/core_ext/time/zones.rb#L89" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-in_time_zone_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/zones.rb, line 89</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">in_time_zone</span>(<span class="ruby-identifier">zone</span> = <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">zone</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">zone</span>
    <span class="ruby-constant">ActiveSupport</span><span class="ruby-operator">::</span><span class="ruby-constant">TimeWithZone</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">utc?</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">self</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">getutc</span>, <span class="ruby-operator">::</span><span class="ruby-constant">Time</span>.<span class="ruby-identifier">find_zone!</span>(<span class="ruby-identifier">zone</span>))
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">self</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-midnight">
            
              <b>midnight</b>()
            
            <a href="Time.html#method-i-midnight" name="method-i-midnight" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-minus_with_coercion">
            
              <b>minus_with_coercion</b>(other)
            
            <a href="Time.html#method-i-minus_with_coercion" name="method-i-minus_with_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Time#- can also be used to determine the number of seconds between two <a
href="Time.html">Time</a> instances. We’re layering on additional behavior
so that <a
href="ActiveSupport/TimeWithZone.html">ActiveSupport::TimeWithZone</a>
instances are coerced into values that Time#- will recognize</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-2D">-</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-minus_with_coercion_source')" id="l_method-i-minus_with_coercion_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L267" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-minus_with_coercion_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 267</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">minus_with_coercion</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-identifier">other</span> = <span class="ruby-identifier">other</span>.<span class="ruby-identifier">comparable_time</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:comparable_time</span>)
  <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">DateTime</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">to_f</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">minus_without_coercion</span>(<span class="ruby-identifier">other</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-minus_without_coercion">
            
              <b>minus_without_coercion</b>(other)
            
            <a href="Time.html#method-i-minus_without_coercion" name="method-i-minus_without_coercion" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-minus_without_duration">
            
              <b>minus_without_duration</b>(other)
            
            <a href="Time.html#method-i-minus_without_duration" name="method-i-minus_without_duration" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-seconds_since_midnight">
            
              <b>seconds_since_midnight</b>()
            
            <a href="Time.html#method-i-seconds_since_midnight" name="method-i-seconds_since_midnight" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Seconds since midnight: Time.now.<a
href="Time.html#method-i-seconds_since_midnight">#seconds_since_midnight</a></p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-seconds_since_midnight_source')" id="l_method-i-seconds_since_midnight_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L83" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-seconds_since_midnight_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 83</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">seconds_since_midnight</span>
  <span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">change</span>(<span class="ruby-value">:hour</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-number">0</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">usec</span> <span class="ruby-operator">/</span> <span class="ruby-number">1.0e+6</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-seconds_until_end_of_day">
            
              <b>seconds_until_end_of_day</b>()
            
            <a href="Time.html#method-i-seconds_until_end_of_day" name="method-i-seconds_until_end_of_day" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns the number of seconds until 23:59:59.</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2012</span>, <span class="ruby-value">8</span>, <span class="ruby-value">29</span>,  <span class="ruby-value">0</span>,  <span class="ruby-value">0</span>,  <span class="ruby-value">0</span>).<span class="ruby-identifier">seconds_until_end_of_day</span> <span class="ruby-comment"># =&gt; 86399</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2012</span>, <span class="ruby-value">8</span>, <span class="ruby-value">29</span>, <span class="ruby-value">12</span>, <span class="ruby-value">34</span>, <span class="ruby-value">56</span>).<span class="ruby-identifier">seconds_until_end_of_day</span> <span class="ruby-comment"># =&gt; 41103</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2012</span>, <span class="ruby-value">8</span>, <span class="ruby-value">29</span>, <span class="ruby-value">23</span>, <span class="ruby-value">59</span>, <span class="ruby-value">59</span>).<span class="ruby-identifier">seconds_until_end_of_day</span> <span class="ruby-comment"># =&gt; 0</span>
</pre>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-seconds_until_end_of_day_source')" id="l_method-i-seconds_until_end_of_day_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L92" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-seconds_until_end_of_day_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 92</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">seconds_until_end_of_day</span>
  <span class="ruby-identifier">end_of_day</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">to_i</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-since">
            
              <b>since</b>(seconds)
            
            <a href="Time.html#method-i-since" name="method-i-since" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns a new <a href="Time.html">Time</a> representing the time a number
of seconds since the instance time</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-in">in</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-since_source')" id="l_method-i-since_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/214e377a329d8b4df5a8cff4b6a7347f1282b384/activesupport/lib/active_support/core_ext/time/calculations.rb#L160" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-since_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/calculations.rb, line 160</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">since</span>(<span class="ruby-identifier">seconds</span>)
  <span class="ruby-keyword">self</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">seconds</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">to_datetime</span>.<span class="ruby-identifier">since</span>(<span class="ruby-identifier">seconds</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_default_s">
            
              <b>to_default_s</b>(format = :default)
            
            <a href="Time.html#method-i-to_default_s" name="method-i-to_default_s" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_formatted_s">
            
              <b>to_formatted_s</b>(format = :default)
            
            <a href="Time.html#method-i-to_formatted_s" name="method-i-to_formatted_s" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Converts to a formatted string. See <a
href="Time.html#DATE_FORMATS">DATE_FORMATS</a> for builtin formats.</p>

<p>This method is aliased to <code>to_s</code>.</p>

<pre class="ruby"><span class="ruby-identifier">time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>                    <span class="ruby-comment"># =&gt; Thu Jan 18 06:10:17 CST 2007</span>

<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">time</span>)         <span class="ruby-comment"># =&gt; &quot;06:10&quot;</span>
<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_s</span>(:<span class="ruby-identifier">time</span>)                   <span class="ruby-comment"># =&gt; &quot;06:10&quot;</span>

<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">db</span>)           <span class="ruby-comment"># =&gt; &quot;2007-01-18 06:10:17&quot;</span>
<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">number</span>)       <span class="ruby-comment"># =&gt; &quot;20070118061017&quot;</span>
<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">short</span>)        <span class="ruby-comment"># =&gt; &quot;18 Jan 06:10&quot;</span>
<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">long</span>)         <span class="ruby-comment"># =&gt; &quot;January 18, 2007 06:10&quot;</span>
<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">long_ordinal</span>) <span class="ruby-comment"># =&gt; &quot;January 18th, 2007 06:10&quot;</span>
<span class="ruby-identifier">time</span>.<span class="ruby-identifier">to_formatted_s</span>(:<span class="ruby-identifier">rfc822</span>)       <span class="ruby-comment"># =&gt; &quot;Thu, 18 Jan 2007 06:10:17 -0600&quot;</span>
</pre>

<h2 id="method-i-to_formatted_s-label-Adding+your+own+time+formats+to+to_formatted_s">Adding your own time formats to <code>to_formatted_s</code></h2>

<p>You can add your own formats to the Time::DATE_FORMATS hash. Use the format
name as the hash key and either a strftime string or Proc instance that
takes a time argument as the value.</p>

<pre># config/initializers/time_formats.rb
Time::DATE_FORMATS[:month_and_year] = '%B %Y'
Time::DATE_FORMATS[:short_ordinal]  = -&gt;(time) { time.strftime(&quot;%B #{time.day.ordinalize}&quot;) }</pre>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-to_s">to_s</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_formatted_s_source')" id="l_method-i-to_formatted_s_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/794a70f94485fb64ed1c49ba8532895306e2001c/activesupport/lib/active_support/core_ext/time/conversions.rb#L46" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_formatted_s_source" class="dyn-source">
                <pre><span class="ruby-comment"># File activesupport/lib/active_support/core_ext/time/conversions.rb, line 46</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_formatted_s</span>(<span class="ruby-identifier">format</span> = <span class="ruby-value">:default</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">formatter</span> = <span class="ruby-constant">DATE_FORMATS</span>[<span class="ruby-identifier">format</span>]
    <span class="ruby-identifier">formatter</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:call</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">formatter</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword">self</span>).<span class="ruby-identifier">to_s</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">strftime</span>(<span class="ruby-identifier">formatter</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">to_default_s</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_s">
            
              <b>to_s</b>(format = :default)
            
            <a href="Time.html#method-i-to_s" name="method-i-to_s" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Time.html#method-i-to_default_s">to_default_s</a>
            </div>
          
          
          
          </div>
                    </div>

    </div>
  </body>
</html>    